package pack4;

import java.util.*;

class Solution2 {
    public boolean uniqueOccurrences(int[] arr) {
        Map<Integer, Integer> countMap = new HashMap<>();

        for (int num : arr) {
            countMap.put(num, countMap.getOrDefault(num, 0) + 1);
        }

        Set<Integer> uniqueCounts = new HashSet<>(countMap.values());

        return uniqueCounts.size() == countMap.size();
    }

    public static void main(String[] args) {
        Solution2 solution = new Solution2();
        int[] arr1 = {1,2,2,1,1,3};
        int[] arr2 = {1,2};
        int[] arr3 = {-3,0,1,-3,1,1,1,-3,10,0};
        System.out.println("测试用例1: " + solution.uniqueOccurrences(arr1));
        System.out.println("测试用例2: " + solution.uniqueOccurrences(arr2));
        System.out.println("测试用例2: " + solution.uniqueOccurrences(arr3));
    }
}